package org.flower.web.servlet;

import org.flower.dao.OrderDao;
import org.flower.dao.impl.OrderDaoImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/**
 * 发货servlet
 *
 * @author Aizen
 * @date 2021/12/29
 */
@WebServlet("/manager/faHuoServlet.shtml")
public class FaHuoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String orderid = request.getParameter("orderid");
        OrderDao od = new OrderDaoImpl();
        boolean fahuo = od.fahuo(orderid);
        if (fahuo){
            response.getWriter().write(
                    "<script type=\"text/javascript\">alert('发货成功！！');setInterval(\"\",10);parent.location.href='" +
                            request.getContextPath()
                            + "/manager/orderListServlet.shtml'</script>");
            response.getWriter().flush();
            response.getWriter().close();
        }else{
            response.getWriter().write(
                    "<script type=\"text/javascript\">alert('发货失败了。。。');setInterval(\"\",10);parent.location.href='" +
                            request.getContextPath()
                            + "/manager/orderListServlet.shtml'</script>");
            response.getWriter().flush();
            response.getWriter().close();
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
